/*
 * @Descripttion: 档案重写页
 * @version:
 * @Author: spring
 * @Date: 2022-04-17 18:19:43
 * @LastEditors: spring
 * @LastEditTime: 2022-04-18 19:58:50
 */
import { memo } from "react";
import { Button, Table, Space, Modal } from "antd";
import { EditOutlined } from "@ant-design/icons";
import { archiverType } from "../../../../types";
import AntdTable from "../../../../components/Table";
const { Column } = Table;
import { column } from "./config";
interface propsObj {
  data: archiverType[];
  loading: boolean;
  deleteTable: Function;
  modifyTable: Function;
}
export default memo(function ArchivesTable(props: propsObj) {
  return (
    <AntdTable
      tableConfig={{
        dataSource: props.data,
        bordered: true,
        rowKey: "id",
        loading: props.loading,
        pagination: false,
      }}
      configColumn={{ column }}
      columnSlot={
        <Column
          title="操作"
          key="cz"
          width={120}
          render={(tags) => (
            <Space size="middle">
              <Button
                type="primary"
                onClick={() => {
                  props.modifyTable({ tags });
                }}
                icon={<EditOutlined />}
              ></Button>
              <Button
                type="primary"
                danger
                onClick={() => {
                  Modal.confirm({
                    title: "是否删除列？",
                    okText: "确认",
                    cancelText: "取消",
                    onOk: () => {
                      props.deleteTable(tags);
                    },
                  });
                }}
              >
                -
              </Button>
            </Space>
          )}
        />
      }
    ></AntdTable>
  );
});
